<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="./css/mian.css">
    <script type="text/javascript" src="scripts/jquery/jquery-1.7.1.js"></script>
    <title>密码修改</title>
</head>

<body>
    <div class="common-header">
        <div class="header-wrap">
            <div class="header-left">
                <p id="sub_title" class="page-title">重置密码</p>
            </div>
            <div class="header-right">
                <div id="login_new" class="header-login"><a href="#" style="color:white">登录</a></div>
                
            </div>
        </div>
    </div>
    <div class="container">
        <div>
            <div class="section section-subnav">
                <div class="section_subnav">
                    <ul class="subnav_process">
                        <li>
                            <div>
                                <i id="i1"  style="background-color: #2f86f6;border-radius: 50%">1</i>
                                <p>填写帐号</p>
                            </div>
                            <i></i>
                        </li>
                        <li>
                            <div>
                                <i id="i2" style="background-color: #7B7B7B;border-radius: 50%">2</i>
                                <p>填写原密码</p>
                            </div>
                            <i></i>
                        </li>
                        <li>
                            <div>
                                <i id="i3" style="background-color: #7B7B7B;border-radius: 50%">3</i>
                                <p>设置新密码</p>
                            </div>
                            <!-- <i></i> -->
                        </li>
                        <!-- <li class="last">
                            <div>
                                <i id="i4" style="background-color: #7B7B7B;border-radius: 50%">4</i>
                                <p>完成</p>
                            </div>
                            <i></i>
                        </li> -->
                    </ul>
                </div>
            </div>
            <div id="step1" class="section section-main">
                <div class="section_main" id="container">
                    <div class="main_form">
                        <form id="input_account_form">
                            <div class="mod-form-block input">
                                <label for="account">帐号：</label>
                                <div>
                                    <div class="formblock medium" style="width:264px">
                                        <input type="text" style="width:264px" id="account" placeholder="帐号"
                                            class="tips-error-border">
                                    </div>
                                    <div class="tips-error-text" style="display: none;" id="account_text">
                                        <div>
                                            <span id="account_span">不能为空</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <a class="mod-btn blue large" href="javascript:void(0);" onclick="gostep2()" id="next_step1"
                                style="margin-top:10px"><span>下一步</span></a>
                        </form>
                    </div>
                </div>
            </div>

            <div id="step2" class="section section-main" style="display: none;">
                <div class="section_main" id="container">
                    <div class="main_form">
                        <form id="input_oldpwd_form">
                            <div class="mod-form-block input">
                                <label for="oldpwd">原密码：</label>
                                <div>
                                    <div class="formblock medium" style="width:264px">
                                        <input type="password" style="width:264px" id="oldpwd" placeholder="原密码"
                                            class="tips-error-border">
                                    </div>
                                    <div class="tips-error-text" style="display: none;" id="oldpwd_text">
                                        <div>
                                            <span id="oldpwd_span">不能为空</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <a class="mod-btn blue large" href="javascript:void(0);" id="next_step2"
                                style="margin-top:10px"><span>下一步</span></a>
                        </form>
                    </div>
                </div>
            </div>

            <div id="step3" class="section section-main"  style="display: none;">
                <div class="section_main" id="container">
                    <div class="main_form">
                        <form id="input_newpwd_form">
                            <div class="mod-form-block input">
                                <label for="newpwd">新密码：</label>
                                <div>
                                    <div class="formblock medium" style="width:264px">
                                        <input type="password" style="width:264px" id="newpwd" placeholder="原密码"
                                            class="tips-error-border">
                                    </div>
                                    <div class="tips-error-text" style="display: none;" id="newpwd_text">
                                        <div>
                                            <span id="newpwd_span">不能为空</span>
                                        </div>
                                    </div>
                                </div>
                                <label for="anewpwd">确认密码：</label>
                                <div>
                                    <div class="formblock medium" style="width:264px">
                                        <input type="password" style="width:264px" id="anewpwd" placeholder="原密码"
                                            class="tips-error-border">
                                    </div>
                                    <div class="tips-error-text" style="display: none;" id="anewpwd_text">
                                        <div>
                                            <span id="anewpwd_span">不能为空</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <a class="mod-btn blue large" href="javascript:void(0);" id="next_step3"
                                style="margin-top:10px"><span>确定</span></a>
                        </form>
                    </div>
                </div>
            </div>
         </div>
      </div>
      <div id="footer_new">
		<p><a href="../main_page/index.html"  target="_blank">关于科成</a>|<a href="../main_page/index.html"  target="_blank">About CDUESTC</a>|<a href="#">服务条款</a>|<a href="#">招生就业</a>|<a href="#">隐私政策</a>|<a href="#">帮助中心<span id="debug"></span></a></p>
		<p>Copyright © 1998 - <span id="current_year">2019</span> CDUESTC. All Rights Reserved. </p>
	  </div>
      <script type="text/javascript">
      var step1 = false;
      	$("#account").blur(function(){
      		if($("#account").val()==null||$("#account").val()==""){
      			step1 = false;
      			$("#account_span").html("不能为空")
      			$("#account_text").css("display","block");
      		}else{
      			$("#account_text").css("display","none");
      			$.ajax({
      				type:"post",
      				url:"/EDUSystem/account/checkAccount.do",
      				data:{"account":$("#account").val()},
      				dataType:"json",
      				success:function suc(dt){//响应成功后的回调函数
      					if(dt.code==-1){
      						step1 = false;
      						$("#account_span").html(dt.message)
      						$("#account_text").css("display","block")
      					}else{
      						step1 = true;
      					}
      				},
      				errer:function err(){
      					alert("服务器出现故障")
      				}
      			});
      		}
      	});
      	
      	function gostep2(){
      		if(step1==true){
      			$("#step1").css("display","none");
      			$("#step2").css("display","block");
      			$("#i2").css("background-color","#2f86f6");
      		}
      	}
      	
      	$("#next_step2").click(function(){
      		if($("#oldpwd").val()==null||$("#oldpwd").val()==""){
      			$("#oldpwd_span").html("不能为空")
      			$("#oldpwd_text").css("display","block");
      		}else{
      			$("#account_text").css("display","none");
      			$.ajax({
      				type:"post",
      				url:"/EDUSystem/account/checkPassword.do",
      				data:{"account":$("#account").val(),
      					"password":$("#oldpwd").val()	
      				},
      				dataType:"json",
      				success:function suc(dt){//响应成功后的回调函数
      					if(dt.code==-1){
      						$("#oldpwd_span").html(dt.message)
      						$("#oldpwd_text").css("display","block");
      					}else{
      						$("#i3").css("background-color","#2f86f6");
      						$("#step2").css("display","none");
      						$("#step3").css("display","block");
      					}
      				},
      				errer:function err(){
      					alert("服务器出现故障")
      				}
      			});
      		}
      	});
      	
      	$("#newpwd").blur(function(){
      		if($("#newpwd").val()==null||$("#newpwd").val()==""){
      			$("#newpwd_span").html("不能为空")
      			$("#newpwd_text").css("display","block");
      		}else{
      			$("#newpwd_text").css("display","none");
      		}
      	});
      	$("#anewpwd").blur(function(){
      		if($("#anewpwd").val()==null||$("#anewpwd").val()==""){
      			$("#anewpwd_span").html("不能为空")
      			$("#anewpwd_text").css("display","block");
      		}else{
      			$("#anewpwd_text").css("display","none");
      		}
      	});
      	
      	
      	$("#next_step3").click(function(){
      		if($("#newpwd").val()==null||$("#newpwd").val()==""){
      			$("#newpwd_span").html("不能为空")
      			$("#newpwd_text").css("display","block");
      		}else if($("#anewpwd").val()==null||$("#anewpwd").val()==""){
      			$("#anewpwd_span").html("不能为空")
      			$("#anewpwd_text").css("display","block");
      		}else if($("#newpwd").val()!=$("#anewpwd").val()){
      			$("#anewpwd_span").html("两次输入密码不一致")
      			$("#anewpwd_text").css("display","block");
      		}else if($("#newpwd").val()!=null&&$("#anewpwd").val()!=null&&$("#newpwd").val()==$("#anewpwd").val()){
      			$.ajax({
      				type:"post",
      				url:"/EDUSystem/account/updatePassword.do",
      				data:{"account":$("#account").val(),
      					"password":$("#newpwd").val()	
      				},
      				dataType:"json",
      				success:function suc(dt){//响应成功后的回调函数
      					if(dt.code==1){
      						alert("修改成功，请重新登录！")
      						parent.location.href="login.html"
      					}else{
      						alert(dt.message)
      					}
      				},
      				errer:function err(){
      					alert("服务器出现故障")
      				}
      			});
      		}
      	});
      	
      </script>
</body>
</html>